package 图.最短路径;

import 抽象数据类型.DirectedEdge;
import 抽象数据类型.EdgeWeightedGraph;

/**
 * @description:
 * @author: ywk
 * @date: 2021-08-14
 */
public class 任意顶点对之间的最短路径 {
    public class DijkstraAllPairsSP{
        private 最短路径的Dijkstra算法.DijkstraSP[] all;

        DijkstraAllPairsSP(EdgeWeightedGraph graph) {
            all = new 最短路径的Dijkstra算法.DijkstraSP[graph.V()];
            for (int v = 0; v < graph.V(); v++) {
                all[v] = new 最短路径的Dijkstra算法.DijkstraSP(graph, v);
            }
        }

        Iterable<DirectedEdge> path(int s, int t) {
            return all[s].pathTo(t);
        }

        double dist(int s, int t) {
            return all[s].distTo(t);
        }
    }
}
